package utils

import (
	"strings"

	"go.mongodb.org/mongo-driver/bson/primitive"
)

func IdToString(id *primitive.ObjectID) string {
	b, _ := id.MarshalJSON()
	return strings.ReplaceAll(string(b), "\"", "")
}

func SliceToString(val []string) string {
	return strings.Join(val, "")
}

func DefaultToVal(val string) string {
	if len(strings.TrimSpace(val)) > 0 {
		return val
	}
	return "Anon"
}

func DatetimeToString(val primitive.DateTime) string {
	return val.Time().Format("2006/01/02 (Mon) 15:04:05")
}
